package com.koron.tool.frame;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.*;
import java.util.List;
import java.util.Vector;

import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;

import com.koron.mybatis.SessionFactory;
import com.koron.tool.MainFrame;
import com.koron.ui.MutableGridLayout;
import com.koron.web.bean.EnumDBBean;
import com.koron.web.bean.EnumDetailDBBean;
import com.koron.web.mapper.UserDefineMapper;

/**
 * 编辑器
 * 
 * @author swan
 *
 */
public class EditorFrame extends JInternalFrame {
	static final char[] list = "─└┴┘├┼┤┌┬┐│".toCharArray();
	private JTextArea jtaContent = new JTextArea();
	private boolean alt = false;
	public MainFrame frame;

	public EditorFrame(MainFrame frame) {
		super("编辑器设置");
		this.frame = frame;
		setSize(800, 600);
		add(new JScrollPane(jtaContent));
		jtaContent.addKeyListener(new KeyAdapter() {
			/*
			 * (non-Javadoc)
			 * 
			 * @see java.awt.event.KeyAdapter#keyTyped(java.awt.event.KeyEvent)
			 */
			@Override
			public void keyTyped(KeyEvent e) {
				if (alt) {
					int ret = ((int) e.getKeyChar()) - '0';
					if (ret == -2)
						ret = 10;
					if (ret >= 0 && ret < 11)
						e.setKeyChar(list[ret]);
				}
				super.keyTyped(e);
			}
		});
		final JToggleButton btn = new JToggleButton("启用制表功能");
		add(btn,BorderLayout.SOUTH);
		btn.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				alt = btn.isSelected();
			}
		});
		setMaximizable(true);
		setClosable(true);
		setIconifiable(true);
		setResizable(true);
	}
	
}
